package com.leetcode;

/**
 * 跳跃游戏
 *
 * @author winson
 * @create 2022-05-05 10:36
 */
public class JumpSolution {

    public boolean canJump(int[] nums) {
        int length = nums.length - 1;
        int rightMost = 0;
        for (int i = 0; i <= length; i++) {
            if (i <= rightMost) {
                rightMost = Math.max(rightMost, i + nums[i]);
                if (rightMost >= length) {
                    return true;
                }
            }
        }
        return false;
    }
}
